package com.faner4cloud.yun.common.constant.enums;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * @author ...zz
 * @version v1
 * @summary 删除标记枚举
 * @since 2022/6/22 11:16 AM
 */
public enum DelFlagEnum {
	/**
	 * 有效
	 */
	EFFECTIVE(1, "有效"),

	/**
	 * 删除
	 */
	DISABLED(0, "删除");

	private Integer code;

	private String value;

	DelFlagEnum(Integer code, String value) {
		this.code = code;
		this.value = value;
	}

	public Integer getCode() {
		return code;
	}

	public String getValue() {
		return value;
	}

	public static Map<Integer, String> toMap() {
		Map<Integer, String> map = Maps.newHashMap();
		for (DelFlagEnum element : DelFlagEnum.values()) {
			map.put(element.getCode(), element.getValue());
		}
		return map;
	}

	public static DelFlagEnum getByCode(Integer code) {
		if (code == null) {
			return null;
		}
		for (DelFlagEnum element : DelFlagEnum.values()) {
			if (code.equals(element.getCode())) {
				return element;
			}
		}
		return null;
	}
}
